///////////////////////////////////////////////////////////
//  SampleSounding.cpp
//  Implementation of the Class SampleSounding
//  Created on:      21-sep-2007 15:40:08
///////////////////////////////////////////////////////////

#include "SampleSounding.h"
#include <iostream>

#define SIZE_PKSAMPLESOUNDING 10
#define SIZE_CODE 5
#define SIZE_BULK_RICHARDSON 10
#define SIZE_CAPE 10
#define SIZE_CAPE_VIRTUAL 10
#define SIZE_CONVECTIVE_INHIBITION 10
#define SIZE_CROSS_TOTALS_INDEX 10
#define SIZE_DATE 11
#define SIZE_HOUR 6
#define SIZE_K_INDEX 10
#define SIZE_LIFTED 10
#define SIZE_LIFTED_VIRTUAL 10
#define SIZE_PRECIPITABLE_WATER 10
#define SIZE_SHOWALTER_INDEX 10
#define SIZE_SWEAT_INDEX 10
#define SIZE_TOTALS_TOTALS_INDEX 10
#define SIZE_VERTICAL_TOTALS_INDEX 12

#define SIZE_PKSAMPLESOUNDING_SCHEMA 16
#define SIZE_CODE_SCHEMA 9
#define SIZE_BULK_RICHARDSON_SCHEMA 15
#define SIZE_CAPE_SCHEMA 4
#define SIZE_CAPE_VIRTUAL_SCHEMA 12
#define SIZE_CONVECTIVE_INHIBITION_SCHEMA 21
#define SIZE_CROSS_TOTALS_INDEX_SCHEMA 18
#define SIZE_DATE_SCHEMA 4
#define SIZE_HOUR_SCHEMA 4
#define SIZE_K_INDEX_SCHEMA 7
#define SIZE_LIFTED_SCHEMA 6
#define SIZE_LIFTED_VIRTUAL_SCHEMA 14
#define SIZE_PRECIPITABLE_WATER_SCHEMA 18
#define SIZE_SHOWALTER_INDEX_SCHEMA 15
#define SIZE_SWEAT_INDEX_SCHEMA 11
#define SIZE_TOTALS_TOTALS_INDEX_SCHEMA 19
#define SIZE_VERTICAL_TOTALS_INDEX_SCHEMA 21


campo SampleSounding::PK[2] = {{"PKSampleSounding",CHAR, SIZE_PKSAMPLESOUNDING },{0,0,0}};
campo SampleSounding::CODE[2] = {{"stationCode",CHAR, SIZE_CODE },{0,0,0}};
campo SampleSounding::BULK_RICHARDSON[2] = {{"bulk_richardson",CHAR, SIZE_BULK_RICHARDSON},{0,0,0}};
campo SampleSounding::CAPE[2] = {{"cape",CHAR, SIZE_CAPE},{0,0,0}};
campo SampleSounding::CAPE_VIRTUAL[2] = {{"cape_virtual",CHAR, SIZE_CAPE_VIRTUAL},{0,0,0}};
campo SampleSounding::CONVECTIVE_INHIBITION[2] = {{"convective_inhibition",CHAR, SIZE_CONVECTIVE_INHIBITION},{0,0,0}};
campo SampleSounding::CROSS_TOTALS_INDEX[2] = {{"cross_totals_index",CHAR, SIZE_CROSS_TOTALS_INDEX},{0,0,0}};
campo SampleSounding::DATE[2] = {{"date",CHAR, SIZE_DATE},{0,0,0}};
campo SampleSounding::HOUR[2] = {{"hour",CHAR, SIZE_HOUR},{0,0,0}};
campo SampleSounding::K_INDEX[2] = {{"k_index",CHAR, SIZE_K_INDEX},{0,0,0}};
campo SampleSounding::LIFTED[2] = {{"lifted",CHAR, SIZE_LIFTED},{0,0,0}};
campo SampleSounding::LIFTED_VIRTUAL[2] = {{"lifted_virtual",CHAR, SIZE_LIFTED_VIRTUAL},{0,0,0}};
campo SampleSounding::PRECIPITABLE_WATER[2] = {{"precipitable_water",CHAR, SIZE_PRECIPITABLE_WATER},{0,0,0}};
campo SampleSounding::SHOWALTER_INDEX[2] = {{"showalter_index",CHAR, SIZE_SHOWALTER_INDEX},{0,0,0}};
campo SampleSounding::SWEAT_INDEX[2] = {{"sweat_index",CHAR, SIZE_SWEAT_INDEX},{0,0,0}};
campo SampleSounding::TOTALS_TOTALS_INDEX[2] = {{"totals_totals_index",CHAR, SIZE_TOTALS_TOTALS_INDEX},{0,0,0}};
campo SampleSounding::VERTICAL_TOTALS_INDEX[2] = {{"vertical_totals_index",CHAR, SIZE_VERTICAL_TOTALS_INDEX},{0,0,0}};

campo SampleSounding::SAMPLESOUNDING_SCHEMA[SIZE_SAMPLESOUNDING_SCHEMA] = {{"PKSampleSounding",CHAR, SIZE_PKSAMPLESOUNDING }, {"stationCode",CHAR, SIZE_CODE }, {"bulk_richardson",CHAR, SIZE_BULK_RICHARDSON}, {"cape",CHAR, SIZE_CAPE}, {"cape_virtual",CHAR, SIZE_CAPE_VIRTUAL}, {"convective_inhibition",CHAR, SIZE_CONVECTIVE_INHIBITION}, {"cross_totals_index",CHAR, SIZE_CROSS_TOTALS_INDEX}, {"date",CHAR, SIZE_DATE}, {"hour",CHAR, SIZE_HOUR}, {"k_index",CHAR, SIZE_K_INDEX}, {"lifted",CHAR, SIZE_LIFTED}, {"lifted_virtual",CHAR, SIZE_LIFTED_VIRTUAL}, {"precipitable_water",CHAR, SIZE_PRECIPITABLE_WATER}, {"showalter_index",CHAR, SIZE_SHOWALTER_INDEX}, {"sweat_index",CHAR, SIZE_SWEAT_INDEX}, {"totals_totals_index",CHAR, SIZE_TOTALS_TOTALS_INDEX}, {"vertical_totals_index",CHAR, SIZE_VERTICAL_TOTALS_INDEX},{0,0,0}};

#ifndef UNO
	#define UNO 1
#endif

#ifndef ZERO
	#define ZERO 0
#endif


SampleSounding::SampleSounding(){

}


SampleSounding::~SampleSounding(){

}

int SampleSounding::getSchemaSize(){
	return  SIZE_SAMPLESOUNDING_SCHEMA;
}

void SampleSounding::setStationCode(std::string code){
	this->stationCode = code;
}
std::string SampleSounding::getStationCode(void){
	return this->stationCode;
} 

std::string SampleSounding::getValor(std::string atribName){

	if (SampleSounding::PK[0].nombre == atribName){
		return this->PKSampleSounding;
	}
	if (SampleSounding::CODE[0].nombre == atribName){
		return this->stationCode;
	}
	if (SampleSounding::BULK_RICHARDSON[0].nombre == atribName){
		return this->bulk_richardson;
	}
	if (SampleSounding::CAPE[0].nombre == atribName){
		return this->cape;
	}
	if (SampleSounding::CAPE_VIRTUAL[0].nombre == atribName){
		return this->cape_virtual;
	}
	if (SampleSounding::CONVECTIVE_INHIBITION[0].nombre == atribName){
		return this->convective_inhibition;
	}
	if (SampleSounding::CROSS_TOTALS_INDEX[0].nombre == atribName){
		return this->cross_totals_index;
	}
	if (SampleSounding::DATE[0].nombre == atribName){
		return this->date;
	}
	if (SampleSounding::HOUR[0].nombre == atribName){
		return this->hour;
	}
	if (SampleSounding::K_INDEX[0].nombre == atribName){
		return this->k_index;
	}
	if (SampleSounding::LIFTED[0].nombre == atribName){
		return this->lifted;
	}
	if (SampleSounding::LIFTED_VIRTUAL[0].nombre == atribName){
		return this->lifted_virtual;
	}
	if (SampleSounding::PRECIPITABLE_WATER[0].nombre == atribName){
		return this->precipitable_water;
	}
	if (SampleSounding::SHOWALTER_INDEX[0].nombre == atribName){
		return this->showalter_index;
	}
	if (SampleSounding::SWEAT_INDEX[0].nombre == atribName){
		return this->sweat_index;
	}
	if (SampleSounding::TOTALS_TOTALS_INDEX[0].nombre == atribName){
		return this->totals_totals_index;
	}
	if (SampleSounding::VERTICAL_TOTALS_INDEX[0].nombre == atribName){
		return this->vertical_totals_index;
	}
	return "";
}


campo * SampleSounding::getCampoPorAtrib(std::string atribName){

	if (SampleSounding::CODE[0].nombre == atribName){
		return SampleSounding::CODE;
	}
	if (SampleSounding::BULK_RICHARDSON[0].nombre == atribName){
		return SampleSounding::BULK_RICHARDSON;
	}
	if (SampleSounding::CAPE[0].nombre == atribName){
		return SampleSounding::CAPE;
	}
	if (SampleSounding::CAPE_VIRTUAL[0].nombre == atribName){
		return SampleSounding::CAPE_VIRTUAL;
	}
	if (SampleSounding::CONVECTIVE_INHIBITION[0].nombre == atribName){
		return SampleSounding::CONVECTIVE_INHIBITION;
	}
	if (SampleSounding::CROSS_TOTALS_INDEX[0].nombre == atribName){
		return SampleSounding::CROSS_TOTALS_INDEX;
	}
	if (SampleSounding::DATE[0].nombre == atribName){
		return SampleSounding::DATE;
	}
	if (SampleSounding::HOUR[0].nombre == atribName){
		return SampleSounding::HOUR;
	}
	if (SampleSounding::K_INDEX[0].nombre == atribName){
		return SampleSounding::K_INDEX;
	}
	if (SampleSounding::LIFTED[0].nombre == atribName){
		return SampleSounding::LIFTED;
	}
	if (SampleSounding::LIFTED_VIRTUAL[0].nombre == atribName){
		return SampleSounding::LIFTED_VIRTUAL;
	}
	if (SampleSounding::PRECIPITABLE_WATER[0].nombre == atribName){
		return SampleSounding::PRECIPITABLE_WATER;
	}
	if (SampleSounding::SHOWALTER_INDEX[0].nombre == atribName){
		return SampleSounding::SHOWALTER_INDEX;
	}
	if (SampleSounding::SWEAT_INDEX[0].nombre == atribName){
		return SampleSounding::SWEAT_INDEX;
	}
	if (SampleSounding::TOTALS_TOTALS_INDEX[0].nombre == atribName){
		return SampleSounding::TOTALS_TOTALS_INDEX;
	}
	if (SampleSounding::VERTICAL_TOTALS_INDEX[0].nombre == atribName){
		return SampleSounding::VERTICAL_TOTALS_INDEX;
	}
	return NULL;
}

void SampleSounding::loadAtribFromNode(XMLNode* node){

	listaXML::const_iterator j = node->hijos.begin();
	std::string nombreNodo;
	for(;j != node->hijos.end() ;j++)
	{
		nombreNodo=(*j)->getNombre();
		if (nombreNodo == "bulk_richardson")
		{
			this->bulk_richardson = (*j)->getContenido();
		}
		else
		{
			if (nombreNodo == "cape")
			{
				this->cape = (*j)->getContenido();
			}
			else
			{
				if (nombreNodo == "cape_virtual")
				{
					this->cape_virtual = (*j)->getContenido();
				}
				else
				{
					if (nombreNodo == "convective_inhibition")
					{
						this->convective_inhibition = (*j)->getContenido();
					}	
					else
					{
						if (nombreNodo == "cross_totals_index")
						{
							this->cross_totals_index = (*j)->getContenido();
						}	
						else
						{
							if (nombreNodo == "date")
							{
								this->date = (*j)->getContenido();
							}
							else
							{
								if (nombreNodo == "hour")
								{
									this->hour = (*j)->getContenido();
								}
								else
								{
									if (nombreNodo == "k_index")
									{
										this->k_index = (*j)->getContenido();
									}
									else
									{
										if (nombreNodo == "lifted")
										{
											this->lifted = (*j)->getContenido();
										}
										else
										{
											if (nombreNodo == "lifted_virtual")
											{
												this->lifted_virtual = (*j)->getContenido();
											}
											else
											{
												if (nombreNodo == "precipitable_water")
												{
													this->precipitable_water = (*j)->getContenido();
												}
												else
												{
													if (nombreNodo == "showalter_index")
													{
														this->showalter_index = (*j)->getContenido();
													}
													else
													{
														if (nombreNodo == "sweat_index")
														{
															this->sweat_index = (*j)->getContenido();
														}
														else
														{
															if (nombreNodo == "totals_totals_index")
															{
																this->totals_totals_index = (*j)->getContenido();
															}
															else
															{
																if (nombreNodo == "vertical_totals_index")
																{
																	this->vertical_totals_index = (*j)->getContenido();
																}
															}
														}
													}
												}
											}
										}
									}
								}
							}
						}	
					}	
				}	
			}
		}
	}
}

//getters
std::string SampleSounding::getBulk_richardson()
{
	return bulk_richardson;
}
std::string SampleSounding::getCape()
{
	return cape;
}
std::string SampleSounding::getCape_virtual()
{
	return cape_virtual;
}
std::string SampleSounding::getConvective_inhibition()
{
	return convective_inhibition;
}
std::string SampleSounding::getCross_totals_index()
{
	return cross_totals_index;
}
std::string SampleSounding::getDate()
{
	return date;
}
std::string SampleSounding::getHour()
{
	return hour;
}
std::string SampleSounding::getK_index()
{
	return k_index;
}
std::string SampleSounding::getLifted()
{
	return lifted;
}
std::string SampleSounding::getLifted_virtual()
{
	return lifted_virtual;
}
std::string SampleSounding::getPrecipitable_water()
{
	return precipitable_water;
}
std::string SampleSounding::getShowalter_index()
{
	return showalter_index;
}
std::string SampleSounding::getSweat_index()
{
	return sweat_index;
}
std::string SampleSounding::getTotals_totals_index()
{
	return totals_totals_index;
}
std::string SampleSounding::getVertical_totals_index()
{
	return vertical_totals_index;
}

std::string SampleSounding::getPKSampleSounding()
{
	return this->PKSampleSounding;
}



//setters
void SampleSounding::setBulk_richardson( std::string br)
{
	bulk_richardson=br;
}
void SampleSounding::setCape( std::string c)
{
	cape=c;
}
void SampleSounding::setCape_virtual( std::string cv )
{
	cape_virtual=cv;
}
void SampleSounding::setConvective_inhibition( std::string ci)
{
	convective_inhibition=ci;
}
void SampleSounding::setCross_totals_index( std::string cti)
{
	cross_totals_index=cti;
}
void SampleSounding::setDate(std::string d)
{
	date=d;
}
void SampleSounding::setHour(std::string h)
{
	hour=h;
}
void SampleSounding::setK_index(std::string ki)
{
	k_index=ki;
}
void SampleSounding::setLifted( std::string l )
{
	lifted=l;
}
void SampleSounding::setLifted_virtual( std::string lv)
{
	lifted_virtual=lv;
}
void SampleSounding::setPrecipitable_water( std::string pw)
{
	precipitable_water=pw;
}
void SampleSounding::setShowalter_index( std::string si )
{
	showalter_index=si;
}
void SampleSounding::setSweat_index( std::string si)
{
	sweat_index=si;
}
void SampleSounding::setTotals_totals_index( std::string tti )
{
	totals_totals_index=tti;
}
void SampleSounding::setVertical_totals_index ( std::string vti )
{
	vertical_totals_index=vti;
}

void SampleSounding::setPKSampleSounding(std::string pk)
{
	PKSampleSounding = pk;
}

campo* SampleSounding::getSchema()
{
	return SampleSounding::SAMPLESOUNDING_SCHEMA;
}

campo* SampleSounding::getPrimaryKey()
{
	return SampleSounding::PK;
}


void SampleSounding::loadRegistro(void* registro)
{
	campo* esquema = NULL;

	char ptrPKSampleSounding[SIZE_PKSAMPLESOUNDING + UNO];
	char ptrStationCode[SIZE_CODE + UNO];
	char ptrBulk_richardson[SIZE_BULK_RICHARDSON + UNO];
	char ptrCape[SIZE_CAPE + UNO];
	char ptrCape_virtual[SIZE_CAPE_VIRTUAL + UNO];
	char ptrConvective_inhibition[SIZE_CONVECTIVE_INHIBITION + UNO];
	char ptrCross_totals_index[SIZE_CROSS_TOTALS_INDEX + UNO];
	char ptrDate[SIZE_DATE + UNO];
	char ptrHour[SIZE_HOUR + UNO];
	char ptrK_index[SIZE_K_INDEX + UNO];
	char ptrLifted[SIZE_LIFTED + UNO];
	char ptrLifted_virtual[SIZE_LIFTED_VIRTUAL + UNO];
	char ptrPrecipitable_water[SIZE_PRECIPITABLE_WATER + UNO];
	char ptrShowalter_index[SIZE_SHOWALTER_INDEX + UNO];
	char ptrSweat_index[SIZE_SWEAT_INDEX + UNO];
	char ptrTotals_totals_index[SIZE_TOTALS_TOTALS_INDEX + UNO];
	char ptrVertical_totals_index[SIZE_VERTICAL_TOTALS_INDEX + UNO];

	memset(ptrPKSampleSounding, ZERO, SIZE_PKSAMPLESOUNDING + UNO);
	memset(ptrStationCode, ZERO, SIZE_CODE + UNO);
	memset(ptrBulk_richardson, ZERO, SIZE_BULK_RICHARDSON + UNO);
	memset(ptrCape, ZERO, SIZE_CAPE + UNO);
	memset(ptrCape_virtual, ZERO, SIZE_CAPE_VIRTUAL + UNO);
	memset(ptrConvective_inhibition, ZERO, SIZE_CONVECTIVE_INHIBITION + UNO);
	memset(ptrCross_totals_index, ZERO, SIZE_CROSS_TOTALS_INDEX + UNO);
	memset(ptrDate, ZERO, SIZE_DATE + UNO);
	memset(ptrHour, ZERO, SIZE_HOUR + UNO);
	memset(ptrK_index, ZERO, SIZE_K_INDEX + UNO);
	memset(ptrLifted, ZERO, SIZE_LIFTED + UNO);
	memset(ptrLifted_virtual, ZERO, SIZE_LIFTED_VIRTUAL + UNO);
	memset(ptrPrecipitable_water, ZERO, SIZE_PRECIPITABLE_WATER + UNO);
	memset(ptrShowalter_index, ZERO, SIZE_SHOWALTER_INDEX + UNO);
	memset(ptrSweat_index, ZERO, SIZE_SWEAT_INDEX + UNO);
	memset(ptrTotals_totals_index, ZERO, SIZE_TOTALS_TOTALS_INDEX + UNO);
	memset(ptrVertical_totals_index, ZERO, SIZE_VERTICAL_TOTALS_INDEX + UNO);

	esquema = this->getSchema();

	RecordHandler::REG_GET(registro, esquema, "PKSampleSounding, stationCode, bulk_richardson, cape, cape_virtual, convective_inhibition, cross_totals_index, date, hour, k_index, lifted, lifted_virtual, precipitable_water, showalter_index, sweat_index, totals_totals_index, vertical_totals_index", ptrPKSampleSounding, ptrStationCode, ptrBulk_richardson, ptrCape, ptrCape_virtual, ptrConvective_inhibition, ptrCross_totals_index, ptrDate, ptrHour, ptrK_index, ptrLifted, ptrLifted_virtual, ptrPrecipitable_water, ptrShowalter_index, ptrSweat_index, ptrTotals_totals_index, ptrVertical_totals_index);
	
	this->PKSampleSounding.clear();
	this->PKSampleSounding += ptrPKSampleSounding;
	
	this->stationCode.clear();
	this->stationCode += ptrStationCode;

	this->bulk_richardson.clear();
	this->bulk_richardson += ptrBulk_richardson;

	this->cape.clear();
	this->cape += ptrCape;

	this->cape_virtual.clear();
	this->cape_virtual += ptrCape_virtual;

	this->convective_inhibition.clear();
	this->convective_inhibition += ptrConvective_inhibition;

	this->cross_totals_index.clear();
	this->cross_totals_index += ptrCross_totals_index;

	this->date.clear();
	this->date += ptrDate;

	this->hour.clear();
	this->hour += ptrHour;

	this->k_index.clear();
	this->k_index += ptrK_index;

	this->lifted.clear();
	this->lifted += ptrLifted;

	this->lifted_virtual.clear();
	this->lifted_virtual += ptrLifted_virtual;

	this->precipitable_water.clear();
	this->precipitable_water += ptrPrecipitable_water;

	this->showalter_index.clear();
	this->showalter_index += ptrShowalter_index;

	this->sweat_index.clear();
	this->sweat_index += ptrSweat_index;

	this->totals_totals_index.clear();
	this->totals_totals_index += ptrTotals_totals_index;

	this->vertical_totals_index.clear();
	this->vertical_totals_index += ptrVertical_totals_index;
	
}


void SampleSounding::saveInRegistro(void* registro)
{
	campo* esquema = NULL;

	char ptrPKSampleSounding[SIZE_PKSAMPLESOUNDING + UNO];
	char ptrStationCode[SIZE_CODE + UNO];
	char ptrBulk_richardson[SIZE_BULK_RICHARDSON + UNO];
	char ptrCape[SIZE_CAPE + UNO];
	char ptrCape_virtual[SIZE_CAPE_VIRTUAL + UNO];
	char ptrConvective_inhibition[SIZE_CONVECTIVE_INHIBITION + UNO];
	char ptrCross_totals_index[SIZE_CROSS_TOTALS_INDEX + UNO];
	char ptrDate[SIZE_DATE + UNO];
	char ptrHour[SIZE_HOUR + UNO];
	char ptrK_index[SIZE_K_INDEX + UNO];
	char ptrLifted[SIZE_LIFTED + UNO];
	char ptrLifted_virtual[SIZE_LIFTED_VIRTUAL + UNO];
	char ptrPrecipitable_water[SIZE_PRECIPITABLE_WATER + UNO];
	char ptrShowalter_index[SIZE_SHOWALTER_INDEX + UNO];
	char ptrSweat_index[SIZE_SWEAT_INDEX + UNO];
	char ptrTotals_totals_index[SIZE_TOTALS_TOTALS_INDEX + UNO];
	char ptrVertical_totals_index[SIZE_VERTICAL_TOTALS_INDEX + UNO];

	memset(ptrPKSampleSounding, ZERO, SIZE_PKSAMPLESOUNDING + UNO);
	memset(ptrStationCode, ZERO, SIZE_CODE + UNO);;
	memset(ptrBulk_richardson, ZERO, SIZE_BULK_RICHARDSON + UNO);
	memset(ptrCape, ZERO, SIZE_CAPE + UNO);
	memset(ptrCape_virtual, ZERO, SIZE_CAPE_VIRTUAL + UNO);
	memset(ptrConvective_inhibition, ZERO, SIZE_CONVECTIVE_INHIBITION + UNO);
	memset(ptrCross_totals_index, ZERO, SIZE_CROSS_TOTALS_INDEX + UNO);
	memset(ptrDate, ZERO, SIZE_DATE + UNO);
	memset(ptrHour, ZERO, SIZE_HOUR + UNO);
	memset(ptrK_index, ZERO, SIZE_K_INDEX + UNO);
	memset(ptrLifted, ZERO, SIZE_LIFTED + UNO);
	memset(ptrLifted_virtual, ZERO, SIZE_LIFTED_VIRTUAL + UNO);
	memset(ptrPrecipitable_water, ZERO, SIZE_PRECIPITABLE_WATER + UNO);
	memset(ptrShowalter_index, ZERO, SIZE_SHOWALTER_INDEX + UNO);
	memset(ptrSweat_index, ZERO, SIZE_SWEAT_INDEX + UNO);
	memset(ptrTotals_totals_index, ZERO, SIZE_TOTALS_TOTALS_INDEX + UNO);
	memset(ptrVertical_totals_index, ZERO, SIZE_VERTICAL_TOTALS_INDEX + UNO);

	strncpy(ptrPKSampleSounding, (char*)this->PKSampleSounding.c_str(), SIZE_PKSAMPLESOUNDING);
	strncpy(ptrStationCode, (char*)this->stationCode.c_str(), SIZE_CODE);
	strncpy(ptrBulk_richardson, (char*)this->bulk_richardson.c_str(), SIZE_BULK_RICHARDSON);
	strncpy(ptrCape, (char*)this->cape.c_str(), SIZE_CAPE);
	strncpy(ptrCape_virtual, (char*)this->cape_virtual.c_str(), SIZE_CAPE_VIRTUAL);
	strncpy(ptrConvective_inhibition, (char*)this->convective_inhibition.c_str(), SIZE_CONVECTIVE_INHIBITION);
	strncpy(ptrCross_totals_index, (char*)this->cross_totals_index.c_str(), SIZE_CROSS_TOTALS_INDEX);
	strncpy(ptrDate, (char*)this->date.c_str(), SIZE_DATE);
	strncpy(ptrHour, (char*)this->hour.c_str(), SIZE_HOUR);
	strncpy(ptrK_index, (char*)this->k_index.c_str(), SIZE_K_INDEX);
	strncpy(ptrLifted, (char*)this->lifted.c_str(), SIZE_LIFTED);
	strncpy(ptrLifted_virtual, (char*)this->lifted_virtual.c_str(), SIZE_LIFTED_VIRTUAL);
	strncpy(ptrPrecipitable_water, (char*)this->precipitable_water.c_str(), SIZE_PRECIPITABLE_WATER);
	strncpy(ptrShowalter_index, (char*)this->showalter_index.c_str(), SIZE_SHOWALTER_INDEX);
	strncpy(ptrSweat_index, (char*)this->sweat_index.c_str(), SIZE_SWEAT_INDEX);
	strncpy(ptrTotals_totals_index, (char*)this->totals_totals_index.c_str(), SIZE_TOTALS_TOTALS_INDEX);
	strncpy(ptrVertical_totals_index, (char*)this->vertical_totals_index.c_str(), SIZE_VERTICAL_TOTALS_INDEX);

	esquema = this->getSchema();

	RecordHandler::REG_SET(registro, esquema, "PKSampleSounding, stationCode, bulk_richardson, cape, cape_virtual, convective_inhibition, cross_totals_index, date, hour, k_index, lifted, lifted_virtual, precipitable_water, showalter_index, sweat_index, totals_totals_index, vertical_totals_index", ptrPKSampleSounding, ptrStationCode, ptrBulk_richardson, ptrCape, ptrCape_virtual, ptrConvective_inhibition, ptrCross_totals_index, ptrDate, ptrHour, ptrK_index, ptrLifted, ptrLifted_virtual, ptrPrecipitable_water, ptrShowalter_index, ptrSweat_index, ptrTotals_totals_index, ptrVertical_totals_index);	

}
XMLNode* SampleSounding::toViewXML(std::string lat,std::string log, std::string elev){

	XMLNode* node = new XMLNode();
	XMLNode* hijo,* hijo1,* hijo2,* hijo3,* hijo4,* hijo5,* hijo6,* hijo7,* hijo8,* hijo9,* hijo10,*hijo11,*hijo12,*hijo13,*hijo14,*hijo15, *hijoLAT, *hijoLOG, *hijoELEV;
	hijo=hijo1=hijo2=hijo3=hijo4=hijo5=hijo6=hijo7=hijo8=hijo9=hijo10=hijo11=hijo12=hijo13=hijo14=hijo15=hijoLAT=hijoLOG=hijoELEV=NULL;
	node->setNombre("record");
	
	hijo = new XMLNode();
	hijo->setNombre("stationCode");
	hijo->setContenido(this->getStationCode());
	node->agregarHijo(hijo);
	
	hijoLAT = new XMLNode();
	hijoLAT->setNombre("latitude");
	hijoLAT->setContenido(lat);
	node->agregarHijo(hijoLAT);
	
	hijoLOG = new XMLNode();
	hijoLOG->setNombre("longitude");
	hijoLOG->setContenido(log);
	node->agregarHijo(hijoLOG);
	
	hijoELEV = new XMLNode();
	hijoELEV->setNombre("elevation");
	hijoELEV->setContenido(elev);
	node->agregarHijo(hijoELEV);
	
	hijo1 = new XMLNode();
	hijo1->setNombre("date");
	hijo1->setContenido(this->getDate());
	node->agregarHijo(hijo1);
	
	hijo2 = new XMLNode();
	hijo2->setNombre("hour");
	hijo2->setContenido(this->getHour());
	node->agregarHijo(hijo2);
	
	hijo3 = new XMLNode();
	hijo3->setNombre("bulk_richardson");
	hijo3->setContenido(this->getBulk_richardson());
	node->agregarHijo(hijo3);
	
	hijo4 = new XMLNode();
	hijo4->setNombre("cape");
	hijo4->setContenido(this->getCape());
	node->agregarHijo(hijo4);

	hijo5 = new XMLNode();
	hijo5->setNombre("cape_virtual");
	hijo5->setContenido(this->getCape_virtual());
	node->agregarHijo(hijo5);

	hijo6 = new XMLNode();
	hijo6->setNombre("convective_inhibition");
	hijo6->setContenido(this->getConvective_inhibition());
	node->agregarHijo(hijo6);

	hijo7 = new XMLNode();
	hijo7->setNombre("cross_totals_index");
	hijo7->setContenido(this->getCross_totals_index());
	node->agregarHijo(hijo7);
	
	hijo8= new XMLNode();
	hijo8->setNombre("k_index");
	hijo8->setContenido(this->getK_index());
	node->agregarHijo(hijo8);
	
	hijo9= new XMLNode();
	hijo9->setNombre("lifted_index");
	hijo9->setContenido(this->getLifted());
	node->agregarHijo(hijo9);

	hijo10= new XMLNode();
	hijo10->setNombre("lifted_virtual");
	hijo10->setContenido(this->getLifted_virtual());
	node->agregarHijo(hijo10);

	hijo11= new XMLNode();
	hijo11->setNombre("precipitable_water");
	hijo11->setContenido(this->getPrecipitable_water());
	node->agregarHijo(hijo11);

	hijo12= new XMLNode();
	hijo12->setNombre("showalter_index");
	hijo12->setContenido(this->getShowalter_index());
	node->agregarHijo(hijo12);

	hijo13= new XMLNode();
	hijo13->setNombre("sweat_index");
	hijo13->setContenido(this->getSweat_index());
	node->agregarHijo(hijo13);
	
	hijo14= new XMLNode();
	hijo14->setNombre("totals_totals_index");
	hijo14->setContenido(this->getTotals_totals_index());
	node->agregarHijo(hijo14);
	
	hijo15= new XMLNode();
	hijo15->setNombre("vertical_totals_index");
	hijo15->setContenido(this->getVertical_totals_index());
	node->agregarHijo(hijo15);


	
	return node;
	
}

std::string SampleSounding::getKey()
{
	return this->PKSampleSounding;
}

void SampleSounding::setKey(std::string key){
	this->PKSampleSounding = key;
}

bool SampleSounding::EsMayor(std::string atributte, Persistent *object){
	return (this->getValor(atributte) > object->getValor(atributte));
}

const SampleSounding & SampleSounding::operator=(const SampleSounding& p)
{
	PKSampleSounding = p.PKSampleSounding;
	stationCode = p.stationCode;
	bulk_richardson = p.bulk_richardson;
	cape = p.cape;
	cape_virtual = p.cape_virtual;
	convective_inhibition = p.convective_inhibition;
	cross_totals_index = p.cross_totals_index;
	date = p.date;
	hour = p.hour;
	k_index = p.k_index;
	lifted = p.lifted;
	lifted_virtual = p.lifted_virtual;
	precipitable_water = p.precipitable_water;
	showalter_index = p.showalter_index;
	sweat_index = p.sweat_index;
	totals_totals_index = p.totals_totals_index;
	vertical_totals_index = p.vertical_totals_index ;
	return (*this);
}

void SampleSounding::print()
{
	std::cout << "PKSAMPLESOUNDING: " << PKSampleSounding << std::endl;
	std::cout << "STATIONCODE: " << stationCode << std::endl;
	std::cout << "BULK_RICHARDSON: " << bulk_richardson << std::endl;
	std::cout << "CAPE: " << cape << std::endl;
	std::cout << "CAPE_VIRTUAL: " << cape_virtual << std::endl;
	std::cout << "CONVECTIVE_INHIBITION: " << convective_inhibition << std::endl;
	std::cout << "CROSS_TOTALS_INDEX: " << cross_totals_index << std::endl;
	std::cout << "DATE: " << date << std::endl;
	std::cout << "HOUR: " << hour << std::endl;
	std::cout << "K_INDEX: " << k_index << std::endl;
	std::cout << "LIFTED: " << lifted << std::endl;
	std::cout << "LIFTED_VIRTUAL: " << lifted_virtual << std::endl;
	std::cout << "PRECIPITABLE_WATER: " << precipitable_water << std::endl;
	std::cout << "SHOWALTER_INDEX: " << showalter_index << std::endl;
	std::cout << "SWEAT_INDEX: " << sweat_index << std::endl;
	std::cout << "TOTALS_TOTALS_INDEX: " << totals_totals_index << std::endl;
	std::cout << "VERTICAL_TOTALS_INDEX: " << vertical_totals_index  << std::endl;
}



